package com.design.softwaredesign.controller;

import com.design.softwaredesign.front.GoodInfo;
import com.design.softwaredesign.service.BackCampusService;
import com.design.softwaredesign.vo.DataVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author :WaiterXiaoYY
 * @description: TODO
 * @data :2020/11/4 23:45
 */

@Api(description = "管理员后台控制层-闲置管理控制")
@RestController
@RequestMapping("/web/admin")
public class BackCampusController {

    @Autowired
    private BackCampusService backCampusService;

    @ApiOperation(value = "获取类型的所有的发布数据")
    @GetMapping("/getallcampusbygoodstate")
    public DataVo getAllCampus(Integer pageNum, Integer pageSize, String query, String goodState) {
        DataVo dataVo = new DataVo();
        dataVo = backCampusService.getAllCampus(pageNum, pageSize, query, goodState);
        return dataVo;
    }

    @ApiOperation(value = "根据goodId和图片链接数组的index删除图片")
    @DeleteMapping("/deletecampusimage/{goodId}/{index}")
    public DataVo deleteCampusImage(@PathVariable String goodId, @PathVariable Integer index) {
        DataVo dataVo = new DataVo();
        dataVo = backCampusService.deleteCampusImage(goodId, index);
        return dataVo;
    }

    @ApiOperation(value = "根据goodId更新Campus信息")
    @PostMapping("/updatecampusinfo")
    public DataVo updatePostInfo(@RequestBody GoodInfo goodInfo) {
        DataVo dataVo = backCampusService.updateCampusInfo(goodInfo);
        return dataVo;
    }

    @ApiOperation(value = "根据goodId删除帖子")
    @DeleteMapping("/deletecampus/{goodId}")
    public DataVo deletePost(@PathVariable String goodId) {
        DataVo dataVo = backCampusService.deleteCampus(goodId);
        return dataVo;
    }

    @ApiOperation(value = "获取闲置的时间线")
    @GetMapping("/getcampustimestamp/{goodId}")
    public DataVo getCampusTimeStamp(@PathVariable String goodId) {
        DataVo dataVo = backCampusService.getCampusTimeStamp(goodId);
        return dataVo;
    }
}
